/**
 * 
 */
package com.share.lottery.base;


import com.share.lottery.R;
import com.share.lottery.view.CustomToast;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;

/**
 * @author py
 * @date 2014-4-18
 * fragment 基类
 * 
 * @version 1.0
 */
public abstract  class BaseFragment extends Fragment implements OnTouchListener,OnClickListener{

	private ProgressDialog pDialog;
	
	public void init(){
	
		findView();
		setData();
		getData();
		setOnClicker();
	}
	public abstract void findView();
	public abstract void setData();
	public abstract void getData();
	public abstract void setOnClicker();
	/**
	 * 弹一个短的土司
	 * 
	 * @param str
	 */
	public void showShortToast(String str) {
		CustomToast.makeText(getActivity(), str, 0);
	}

	public void showProgreessDialog(Context context) {

		if (pDialog == null) {
			pDialog = new ProgressDialog(context);
			pDialog.setMessage("数据加载中..");
		}
		pDialog.setMessage("数据加载中..");
		pDialog.show();
	}

	public void dismissProgressDialog() {
		if (pDialog != null) {
			pDialog.dismiss();
		}
	}

	public void showActivity(Class<?> classz, boolean finish) {
		Intent intent = new Intent(getActivity(), classz);
		startActivity(intent);
		
		if (finish) {
			getActivity().finish();
		}
		
		 getActivity().overridePendingTransition(R.anim.in_from_right,R.anim.out_to_right);
//		getActivity().overridePendingTransition(R.anim.in_from_right,0); 
	}
	
	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		 getActivity().overridePendingTransition(R.anim.in_from_right,R.anim.out_to_right);
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		return false;
	}
	
	
}
